cmake_minimum_required(VERSION 3.14)
#设置工程名字
project(katevi LANGUAGES CXX)
project(katevi VERSION 1.0)

set(CMAKE_AUTOUIC ON) #自动用qt的uic程序处理.ui文件
set(CMAKE_AUTOMOC ON) #自动用QT的moc程序处理
set(CMAKE_AUTORCC ON) #自动用qt的qcc程序处理资源文件

#设置支持c17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#添加导出标志宏定义
add_compile_definitions(KATEVI_STATIC_DEFINE)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
 # 比较版本号
if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "5.15.9")
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS   Widgets  Gui   Core5Compat )
else()
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS   Widgets Gui )
endif()
  
include(src/include/include.cmake)
include(src/emulatedcommandbar/emulatedcommandbar.cmake)
include(src/modes/modes.cmake)
include(src/src.cmake)   

add_library(katevi STATIC 
    ${SRC_SOURCES}
    ${INCLUDE_SOURCES}
    ${EMULATED_COMMAND_BAR_SOURCES}
    ${MODES_SOURCES}
)
 
message(${CMAKE_BINARY_DIR})
# 设置动态库输出目录
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# 设置静态库输出目录
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

set_target_properties(katevi PROPERTIES OUTPUT_NAME "katevi")
#将对应的库连接到目标，类似与QT的pro文件的 -l  ,这里的第一个参数是add_library的第一个参数名.
target_link_libraries(katevi PRIVATE Qt${QT_VERSION_MAJOR}::Core)
target_link_libraries(katevi PRIVATE Qt${QT_VERSION_MAJOR}::Gui)
target_link_libraries(katevi PRIVATE Qt${QT_VERSION_MAJOR}::Widgets) 

if(${QT_VERSION_MAJOR} VERSION_GREATER_EQUAL "5.15.9")
    target_link_libraries(katevi PRIVATE Qt${QT_VERSION_MAJOR}::Core5Compat)
endif()
 
